<extend name="./Application/Common/View/block/base.php" />
<block name="header">
    <include file="./Application/Admin/View/block/easyui_header.php" />
    <include file="./Application/Admin/View/block/amap_header.php" />
    <link href="__PUBLIC__/css/Content/index.css" rel="stylesheet" type="text/css" />
    <style>
        #dg{
            height: 100%;;
        }
    </style>
    <script>
        $(function(){
            $('#rivergateTree').tree({
                method: 'get',
                checkbox : false,
                lines: true,
                url : '/Manage/AdminGate/get_river_gate_tree',
                checkbox:true,

            });

        });


        function export_xls(){
            if(getChecked()==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的河道闸门',showType:'slide'});
                return;
            }
            $('#gtx_window').window('open');
        }

        function bz_xls(){
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的河道闸门',showType:'slide'});
                return;
            }
            $('#zb_window').window('open');
        }

        function check_check(){
            var s = getChecked();
            if(s==''){
                $.messager.show({title:'提示',msg:'请勾选需要导出的河闸',showType:'slide'});
                return false;
            }
            return true;
        }

        function getChecked(){
            var nodes = $('#rivergateTree').tree('getChecked');
            var s = '';
            for(var i=0; i<nodes.length; i++){
                if (!$('#rivergateTree').tree('isLeaf', nodes[i].target)||isNaN(nodes[i].id)) {
                    continue;
                }
                if (s != '') s += ',';
                s += nodes[i].id;
            }
            return s;
        }
    </script>
</block>
<block name="bdoy">
    <body>
    <input type="hidden" id="dsfg" name="dsfg" value="dsfg"/>
    <input type="hidden" id="rivergate_id" name="rivergate_id"/>
    <div class="easyui-layout" style="width:100%;height: 500px;"  fit="true">
        <div data-options="region:'west',split:true" title="{:LANG('ravier_gate')}" style="width:240px;">

            <ul id="rivergateTree" class="easyui-tree"></ul>
        </div>
        <div data-options="region:'center'">
            <div class="easyui-window" title="泵站分公司" style="width:300px;height:150px;padding:5px;">
                <table class="form-table">
                    <tr>
                        <td width="100" align="center">起始日期：</td>
                        <td><input id="start_date" class="easyui-datetimebox textbox" editable="false""></td>
                    </tr>
                    <tr>
                        <td width="100" align="center">结束日期：</td>
                        <td><input id="end_date" class="easyui-datetimebox textbox" editable="false"></td>
                    </tr>
                </table>
                <table class="form-table">
                    <tr>
                        <td align="center" colspan="2">
                            <a href="javascript:split_gate()" class="easyui-linkbutton" style="width:120px">闸门记录表</a>
                        </td>
                    </tr>
                </table>
            </div>
        </div>
    </div>
    <div id="gtx_window" class="easyui-window" closed="true" title="导出报表" data-options="modal:true" style="width:300px;height:250px;padding:0px;overflow: hidden;">
        <form id="form">
            <table class="form-table">
                <tr>
                    <td width="100" align="center">起始日期：</td>
                    <td><input id="start_date" class="easyui-datetimebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('start_date')}'"></td>
                </tr>
                <tr>
                    <td width="100" align="center">结束日期：</td>
                    <td><input id="end_date" class="easyui-datetimebox textbox" required data-options="validType:'md[\'10/11/2012\']',prompt:'{:LANG('pls_slet')}{:LANG('end_date')}'"></td>
                </tr>
                <tr>
                    <td align="center" colspan="2">
                        <a href="javascript:export_excel()" class="easyui-linkbutton" style="width:120px">{:LANG('export')}</a>
                    </td>
                </tr>
            </table>
        </form>
    </div>
    </body>
</block>
<block name="footExtendJs">
    <script type="text/javascript">
        $(function(){

        });

        function split_gate(){
            var temp_ids = getChecked();
            if(!check_check()){
                return;
            }
            export_gate(temp_ids);

//            temp_ids = temp_ids.split(",");
//            for(var i=0;i<temp_ids.length;i++){
//                export_gate(temp_ids[i]);
//            }
        }

        function export_gate(id){
            var start = $('#start_date').datetimebox('getValue');
            var end = $('#end_date').datetimebox('getValue');
            var url = '/Manage/AdminGate/export_record?pid='+id+'&start='+start+'&end='+end;
            window.open(url);
        }
    </script>
</block>
